//
//  Created by  fred on 2017/1/12.
//  Copyright © 2016年 Alibaba. All rights reserved.
//

package com.moxiao.yfjh.module.blind.utils.aliyun;

import com.alibaba.cloudapi.sdk.client.ApacheHttpClient;
import com.alibaba.cloudapi.sdk.enums.HttpMethod;
import com.alibaba.cloudapi.sdk.enums.ParamPosition;
import com.alibaba.cloudapi.sdk.enums.Scheme;
import com.alibaba.cloudapi.sdk.model.ApiCallback;
import com.alibaba.cloudapi.sdk.model.ApiRequest;
import com.alibaba.cloudapi.sdk.model.ApiResponse;
import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;

public class AliHttpsApiClient extends ApacheHttpClient {
    public final static String HOST = "selfiev2.market.alicloudapi.com";
    static AliHttpsApiClient instance = new AliHttpsApiClient();

    public static AliHttpsApiClient getInstance() {
        return instance;
    }

    public void init(HttpClientBuilderParams httpClientBuilderParams) {
        httpClientBuilderParams.setScheme(Scheme.HTTPS);
        httpClientBuilderParams.setHost(HOST);
        super.init(httpClientBuilderParams);
    }


    public void verify_selfie_idnumber(String image, String image_url, String id_number, String name, Boolean auto_rotate, ApiCallback callback) {
        String path = "/face/verify_selfie_idnumber";
        ApiRequest request = new ApiRequest(HttpMethod.POST_FORM, path);
        request.addParam("image", image, ParamPosition.BODY, false);
        request.addParam("image_url", image_url, ParamPosition.BODY, false);
        request.addParam("id_number", id_number, ParamPosition.BODY, true);
        request.addParam("name", name, ParamPosition.BODY, true);
        request.addParam("auto_rotate", String.valueOf(auto_rotate), ParamPosition.BODY, false);


        sendAsyncRequest(request, callback);
    }

    public ApiResponse verify_selfie_idnumberSyncMode(String image_url, String id_number, String name, Boolean auto_rotate) {
        String path = "/face/verify_selfie_idnumber";
        ApiRequest request = new ApiRequest(HttpMethod.POST_FORM, path);
//        request.addParam("image" , image , ParamPosition.BODY , false);
        request.addParam("image_url", image_url, ParamPosition.BODY, false);
        request.addParam("id_number", id_number, ParamPosition.BODY, true);
        request.addParam("name", name, ParamPosition.BODY, true);
        request.addParam("auto_rotate", String.valueOf(auto_rotate), ParamPosition.BODY, false);


        return sendSyncRequest(request);
    }

}
